<template>
    <div class="homeIcon">
        <swiper :options="swiperOption">
            <swiper-slide v-for="(page, index) of pages" :key="index">
                <div class="eachIcon" v-for="item of page" :key="item.id">
                    <div class="eachIcon-Img">
                        <img class='ImgLink' :src='item.imgUrl' />
                    </div>
                    <p class="desc">{{item.desc}}</p>
                </div>
            </swiper-slide>
        </swiper>
    </div>
</template>

<script>
export default {
    name: 'HomeIcons',
    props: {
        list: Array
    },
    data() {
        return {
            swiperOption: {
                autoplay: false
            }
        }
    },
    computed: {
        pages () {
            const pages = []
            this.list.forEach((item, index) => {
                const page  = Math.floor(index / 8)
                if (!pages[page]) {
                    pages[page] = []
                }
                pages[page].push(item)
            })
            return pages
        }
    }
}
</script>

<style lang='stylus' scoped>
@import '~styles/varibles.styl'
@import '~styles/maxins.styl'
    .homeIcon >>> .swiper-container
        height: 0
        padding-bottom: 50% 
        .eachIcon
            position: relative
            float: left
            height: 0
            padding-bottom: 25%
            width: 25%
            overflow: hidden
            .eachIcon-Img
                position: absolute
                top: 0
                height: 0
                bottom: .44rem
                padding: .05rem
                .ImgLink
                    width: 70%
                    display: block
                    margin: 0 auto
            .desc
                position: absolute
                width: 100%
                bottom: 0
                height: .44rem
                line-height: .44rem 
                text-align: center
                color: $IconNameColor
                ellipsis()
</style>
